#include<iostream>
using namespace std;
template <class T>
struct Node
{
    T data;
    struct Node<T>* next;
};

template<class T>
class LinkStack
{
private:
    struct Node<T>* top;
public:
    LinkStack(/* args */);
    ~LinkStack();
    void Push(T x);
    T Pop();
    T GetTop();
    bool Empty()
    {
        return (NULL==top)?true:false;
    }
};
template<class T>
LinkStack<T>::LinkStack(/* args */)
{
    top=NULL;
}
template<class T>
LinkStack<T>::~LinkStack()
{
    while (top)
    {
        struct Node<T> *p=top;
        top=top->next;
        delete p;
    }
}
template<class T>
void LinkStack<T>::Push(T x)
{
    struct Node<T>* p=new Node<T>;
    p->data=x;
    p->next=top;
    top=p;
}
template<class T>
T LinkStack<T>::Pop()
{
    if(Empty())throw"下溢";
    T x=top->data;
    struct Node<T>* p=top;
    top=top->next;
    delete p;
    return x;
}